/*
 * SEGUNDA ENTREGA DEL PROYECTO DE BASES DE DATOS "BIBLIOTECA DIGITAL"
 * 
 * Integrantes:
 * Gamboa Edwin Ricardo Cód: 0926631 plan: 2711
 * Portilla Cortes Maria Cristina Cód: 0844113 plan: 3743 
 * Rosero Rosero Luis Alberto Cód: 0943740 plan:3743
 * 
 */

/*
 * GUIAdministrador.java
 *
 * Created on May 4, 2011, 1:26:11 AM
 */


package gui;
import javax.swing.*;
 
public class GUIAdministrador extends javax.swing.JFrame {
    String codigo;
    /** Creates new form GUIAdministrador */
    public GUIAdministrador() {
        initComponents();         
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel5 = new javax.swing.JPanel();
        jPanelFunciones = new javax.swing.JPanel();
        BGestionarUsuarios = new javax.swing.JButton();
        BReportes = new javax.swing.JButton();
        BMiPerfil = new javax.swing.JButton();
        jPanelCentral = new javax.swing.JPanel();
        jLabel57 = new javax.swing.JLabel();
        jBCerrarSesion = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Tipo Usuario: Administrador");
        setAlwaysOnTop(true);
        setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        setForeground(new java.awt.Color(204, 204, 204));
        setResizable(false);

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));

        jPanelFunciones.setBackground(new java.awt.Color(242, 242, 242));
        jPanelFunciones.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(235, 30, 30)));

        BGestionarUsuarios.setBackground(new java.awt.Color(255, 255, 255));
        BGestionarUsuarios.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        BGestionarUsuarios.setForeground(new java.awt.Color(235, 30, 30));
        BGestionarUsuarios.setMnemonic('U');
        BGestionarUsuarios.setText("Gestionar Usuarios");
        BGestionarUsuarios.setToolTipText("Pulse para registrar, modificar perfiles o desactivar usuarios.");
        BGestionarUsuarios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BGestionarUsuariosActionPerformed(evt);
            }
        });

        BReportes.setBackground(new java.awt.Color(255, 255, 255));
        BReportes.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        BReportes.setForeground(new java.awt.Color(235, 30, 30));
        BReportes.setMnemonic('R');
        BReportes.setText("Reportes");
        BReportes.setToolTipText("Pulse para generar reportes con información estadística de la Biblioteca.");
        BReportes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BReportesActionPerformed(evt);
            }
        });

        BMiPerfil.setBackground(new java.awt.Color(255, 255, 255));
        BMiPerfil.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        BMiPerfil.setForeground(new java.awt.Color(235, 30, 30));
        BMiPerfil.setMnemonic('P');
        BMiPerfil.setText("Mi Perfil");
        BMiPerfil.setToolTipText("Pulse para ver y modifcar su información personal.");
        BMiPerfil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                BMiPerfilActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanelFuncionesLayout = new javax.swing.GroupLayout(jPanelFunciones);
        jPanelFunciones.setLayout(jPanelFuncionesLayout);
        jPanelFuncionesLayout.setHorizontalGroup(
            jPanelFuncionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFuncionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanelFuncionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(BGestionarUsuarios, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                    .addComponent(BReportes, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                    .addComponent(BMiPerfil, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanelFuncionesLayout.setVerticalGroup(
            jPanelFuncionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelFuncionesLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(BGestionarUsuarios)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(BReportes)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(BMiPerfil)
                .addContainerGap(578, Short.MAX_VALUE))
        );

        jPanelCentral.setBackground(new java.awt.Color(255, 255, 255));
        jPanelCentral.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(235, 30, 30)));

        jLabel57.setBackground(new java.awt.Color(255, 255, 255));
        jLabel57.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/imagen.JPG"))); // NOI18N

        jBCerrarSesion.setBackground(new java.awt.Color(255, 255, 255));
        jBCerrarSesion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/cerrarSesion.png"))); // NOI18N
        jBCerrarSesion.setToolTipText("Pulse para cerrar sesión.");
        jBCerrarSesion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCerrarSesionActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanelFunciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanelCentral, javax.swing.GroupLayout.DEFAULT_SIZE, 821, Short.MAX_VALUE))
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel57, javax.swing.GroupLayout.DEFAULT_SIZE, 929, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBCerrarSesion, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(13, 13, 13)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel57, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBCerrarSesion, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanelFunciones, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanelCentral, javax.swing.GroupLayout.DEFAULT_SIZE, 694, Short.MAX_VALUE))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void BGestionarUsuariosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BGestionarUsuariosActionPerformed
        // TODO add your handling code here:
        this.validate();
        this.repaint();
        PanelGestionUsuarios panelCentral = new PanelGestionUsuarios();
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(false, true, true, true, true);
        this.validate();
        this.repaint();
        System.out.println("Panel gestion material");
}//GEN-LAST:event_BGestionarUsuariosActionPerformed

    private void BReportesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BReportesActionPerformed
        // TODO add your handling code here:
        this.validate();
        this.repaint();
        PanelReportes panelCentral = new PanelReportes();
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(true, false, true, true, true);
        this.validate();
        this.repaint();
        System.out.println("Panel Reportes");
}//GEN-LAST:event_BReportesActionPerformed

    private void BMiPerfilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BMiPerfilActionPerformed
        // TODO add your handling code here:
        this.validate();
        this.repaint();
        PanelMiperfil panelCentral = new PanelMiperfil(codigo);    
        panelCentral.llenarFormulario();
        jPanelCentral.removeAll();
        jPanelCentral.add(panelCentral);
        activarBotones(true, true, true, true, false);
        this.validate();
        this.repaint();
        System.out.println("Panel consulta general");
}//GEN-LAST:event_BMiPerfilActionPerformed

    private void jBCerrarSesionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCerrarSesionActionPerformed
        // TODO add your handling code here:
        int respuesta = JOptionPane.showConfirmDialog(this, "¿Esta seguro "
                    + "que desea Cerrar la Sesión?");
        if(respuesta == JOptionPane.YES_OPTION)
            System.exit(0);
    }//GEN-LAST:event_jBCerrarSesionActionPerformed

    public void setCodigo(String codigo){
        this.codigo = codigo;
    }
    
    public void activarBotones(Boolean gm, Boolean og, Boolean cg, 
            Boolean ca, Boolean mp){
        BGestionarUsuarios.setEnabled(gm);
        BReportes.setEnabled(og);
        /*BConsultaGeneral.setEnabled(cg);
        BConsultaAvanzada.setEnabled(ca);*/
        BMiPerfil.setEnabled(mp);
    }
    /**
    * @param args the command line arguments
    */
   /* public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new GUIAdministrador();
            }
        });
    }*/

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton BGestionarUsuarios;
    private javax.swing.JButton BMiPerfil;
    private javax.swing.JButton BReportes;
    private javax.swing.JButton jBCerrarSesion;
    private javax.swing.JLabel jLabel57;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanelCentral;
    private javax.swing.JPanel jPanelFunciones;
    // End of variables declaration//GEN-END:variables

}
